// For Country Name, allow input of alphabets, period and allow space
// vtype: 'alphaSpacePeriod'
Ext.form.VTypes['alphaSpacePeriodVal'] = /^[-\.\sA-Za-z]+$/;
Ext.form.VTypes['alphaSpacePeriodMask']=/^[-\.\sA-Za-z]+$/;
Ext.form.VTypes['alphaSpacePeriodText'] = 'Not a valid state, must not contain numbers.';
Ext.form.VTypes['alphaSpacePeriod'] = function(v)
{
    return Ext.form.VTypes['alphaSpacePeriodVal'].test(v);
}

// Allow alphabets and space
// vtype: 'alphaSpace'
Ext.form.VTypes['alphaSpaceVal'] = /^[-\sA-Za-z]+$/;
Ext.form.VTypes['alphaSpaceMask']=/^[-\sA-Za-z]+$/;
Ext.form.VTypes['alphaSpaceText'] = 'Not a valid state, must not contain numbers.';
Ext.form.VTypes['alphaSpace'] = function(v)
{
    return Ext.form.VTypes['alphaSpaceVal'].test(v);
}

// For validating Start Date <= End Date
// vtype: 'daterange'
// *Need to specify 'startDateField' & 'endDateField''
Ext.form.VTypes['daterange'] = function(val, field) {
    var date = field.parseDate(val);

    if(!date){
        return false;
    }
    if (field.startDateField) {
        var start = Ext.getCmp(field.startDateField);
        if (!start.maxValue || (date.getTime() != start.maxValue.getTime())) {
            start.setMaxValue(date);
            start.validate();
        }
    }
    else if (field.endDateField) {
        var end = Ext.getCmp(field.endDateField);
        if (!end.minValue || (date.getTime() != end.minValue.getTime())) {
            end.setMinValue(date);
            end.validate();
        }
    }
    /*
     * Always return true since we're only using this vtype to set the
     * min/max allowed values (these are tested for after the vtype test)
     */
    return true;
}

